/*
 * Copyright (C) 2003, Velocityme Partnership
 * OrganisationBean.java
 *
 * Created on 25 August 2003, 04:40
 */

package com.velocityme.entity;

import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import com.velocityme.interfaces.*;
import com.velocityme.valueobjects.OrganisationValue;

/**
 *
 * @author  Robert Crida Work
 * @ejb.bean
 *           type="CMP"
 *           cmp-version="2.x"
 *           name="Organisation"
 *           jndi-name="ejb/Organisation"
 *           view-type="local"
 * @ejb.transaction type="Required"
 *
 * @ejb.value-object match="*"
 *
 * @ejb.persistence table-name="organisation"
 *
 * @ejb.util generate="physical"
 *
 * @ejb.finder signature="java.util.Collection findAll()"
 *              query="SELECT OBJECT(o) FROM Organisation o WHERE o.contactableLocal.nodeLocal.dBObjectLocal.isDeleted = FALSE"
 *
 * @jboss.persistence create-table="true"
 *                    remove-table="false"
 */
public abstract class OrganisationBean implements EntityBean {
    
    /**
    * Context set by container
    */
    private javax.ejb.EntityContext m_entityContext;

    public void setEntityContext(javax.ejb.EntityContext entityContext) {
        m_entityContext = entityContext;
    }

    public void unsetEntityContext() {
        m_entityContext = null;
    }
  
    /** @ejb.create-method */
    public com.velocityme.interfaces.OrganisationPK ejbCreate(com.velocityme.interfaces.ContactableLocal p_contactableLocal,
                                                              com.velocityme.valueobjects.OrganisationValue p_value) throws CreateException {
        setOrganisationId(p_contactableLocal.getContactableId());
        // EJB 2.0 spec says return null for CMP ejbCreate methods.
        return null;
    }

    public void ejbPostCreate(com.velocityme.interfaces.ContactableLocal p_contactableLocal,
                              com.velocityme.valueobjects.OrganisationValue p_value) throws CreateException {
        // CMR relations must be set in ejbPostCreate
        setOrganisationValue(p_value);
        setContactableLocal(p_contactableLocal);
    }

    /**
     *  This gets a local object from a remote object.
     *  @ejb.interface-method view-type="remote"
     */
    public com.velocityme.interfaces.OrganisationLocal getLocal() {
        return (OrganisationLocal)m_entityContext.getEJBLocalObject();
    }
    
    /** @ejb.interface-method view-type="local" */
    public abstract com.velocityme.valueobjects.OrganisationValue getOrganisationValue();
    /** @ejb.interface-method view-type="local" */
    public abstract void setOrganisationValue(com.velocityme.valueobjects.OrganisationValue p_value);
    
    //=======================================================================
    //
    //                   ATTRIBUTES
    //
    //=======================================================================
      
    /**
     * @ejb.persistence column-name="organisationId"
     * @ejb.interface-method view-type="local"
     * @ejb.pk-field 
     */
    public abstract java.lang.Integer getOrganisationId();
    /** @ejb.interface-method view-type="local" */
    public abstract void setOrganisationId(java.lang.Integer organisationId);

    //=======================================================================
    //
    //                   RELATIONSHIPS
    //
    //=======================================================================
    
    /**
     * @ejb.interface-method view-type="local"
     * @ejb.relation name="Organisation-Contactable"
     *               role-name="Organisation-has-a-Contactable"
     * @jboss.relation fk-column="contactableIdFk"
     *                 related-pk-field="contactableId"
     * @ejb.value-object match="*" 
     *                   aggregate="com.velocityme.valueobjects.ContactableValue"
     *                   aggregate-name="ContactableValue"
     */
    public abstract com.velocityme.interfaces.ContactableLocal getContactableLocal();
    /** @ejb.interface-method view-type="local" */
    public abstract void setContactableLocal(com.velocityme.interfaces.ContactableLocal contactableLocal);
    
    //=======================================================================
    //
    //                   MANAGEMENT METHODS
    //
    //=======================================================================
    
}
